<?php

function daemon() 
{
	$pid = pcntl_fork ();
	if ($pid == - 1) {
		die ( "fork failed for daemon" );
	} else if ($pid) {
		exit ();
	} else {
		if (posix_setsid () == - 1) {
			die ( "could not detach from terminal" );
		}
	}
}

function debugLog($str) {
	echo '['.date('Y-m-d H:i:s').'] '.$str."\n";
}
